/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.suspend.b.c;

import android.content.Context;
import android.text.TextUtils;
import java.io.FileOutputStream;
import java.io.InputStream;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpParams;

public class a {
    public static boolean a(Context paramContext, String paramString1, String paramString2) {
        if ((paramContext == null) || (TextUtils.isEmpty(paramString1)) || (TextUtils.isEmpty(paramString2)))
            return false;
        paramString1 = paramString1.trim();
        paramString1 = paramString1.replace(" ", "");
        HttpGet localHttpGet = new HttpGet(paramString1);
        HttpResponse localHttpResponse = new DefaultHttpClient().execute(localHttpGet);
        if ((localHttpResponse.getStatusLine() != null) && (localHttpResponse.getEntity() != null)
                && (localHttpResponse.getStatusLine().getStatusCode() == 200)) {
            HttpParams localHttpParams = localHttpResponse.getParams();
            HttpHost localHttpHost = com.qihoo.gamecenter.sdk.suspend.b.b.b.c(paramContext);
            if (localHttpHost != null)
                localHttpParams.setParameter("http.route.default-proxy", localHttpHost);
            InputStream localInputStream = localHttpResponse.getEntity().getContent();
            FileOutputStream localFileOutputStream = new FileOutputStream(paramString2);
            byte[] arrayOfByte = new byte[131072];
            int i = 0;
            while ((i = localInputStream.read(arrayOfByte)) != -1)
                localFileOutputStream.write(arrayOfByte, 0, i);
            localFileOutputStream.close();
            localInputStream.close();
        }
        else {
            com.qihoo.gamecenter.sdk.suspend.b.b.a("NetDownLoad",
                    "downloadFile     httpResponse.getStatusLine().getStatusCode() != 200");
            return false;
        }
        return true;
    }
}